import java.util.Objects;
import java.util.Scanner;

public class Members {

    String name;  //会员姓名
    String MembershipNo,//会员号
            MobilePhoneNo;//手机号
    int integral;//积分
    Members[] ar = new Members[100];





    public void xxx() {
        for (int a = 0; a < ar.length; a++) {
            ar[a] = new Members();
            ar[a].name = "a" + a;
            ar[a].MobilePhoneNo = "158" + 1;
            ar[a].MembershipNo = "189" + a;
        }
    }

    public boolean kaika(String name, String MembershipNo, String MobilePhoneNo) {
        for (int a = 0; a < ar.length; a++) {
            if (!Objects.equals(ar[a].MembershipNo, MembershipNo) && ar[a] != null) {
                return false;
            } else if (ar[a] == null) {
                ar[a] = new Members();
                ar[a].name = name; //会员姓名
                ar[a].MembershipNo = MembershipNo;//会员号
                ar[a].MobilePhoneNo = MobilePhoneNo;//手机号
//                ar[a].integral=integral;//积分
                return true;
            }

        }
        System.out.println("录入失败");
        return false;
    }

    boolean inc(String cardNo, int fen) {
        for (int a = 0; a < ar.length; a++) {
            if (ar[a].MembershipNo.equals(cardNo)) {
                ar[a].integral = fen;
                return true;
            }
        }
        return false;
    }

    public String duihuan(String cardNo, int MembershipNo1) {
        for (int a = 0; a < ar.length; a++) {
            if (ar[a].MembershipNo.equals(cardNo)) {
                if (MembershipNo1 == 1 && ar[a].integral >= 100) {
                    ar[a].integral -= 100;
                    return "兑换成功,还有" + ar[a].integral + "积分";
                } else if (MembershipNo1 == 2 && ar[a].integral >= 400) {
                    ar[a].integral -= 400;
                    return "兑换成功,还有" + ar[a].integral + "积分";
                } else if (MembershipNo1 == 3 && ar[a].integral >= 1000) {
                    ar[a].integral -= 1000;
                    return "兑换成功,还有" + ar[a].integral + "积分";
                }

            }
        }
        return "兑换失败";
    }


    public void show() {
        for (Members members : ar) {
            if (members != null) {
                System.out.println("会员姓名:" + members.name + "\t会员号:" + members.MembershipNo + " \t手机号:" + members.MobilePhoneNo + "\t积分：" + members.integral);
            }
        }
    }

}
